package view.views.dialogContentViews;

import java.awt.Dimension;
import java.awt.FlowLayout;
import java.util.ArrayList;

import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;

import model.Constants;
import model.IPAddress;
import controller.Controller;

public class MultiInfoAddPanel extends JPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public MultiInfoAddPanel() {

		JPanel content = new JPanel();
		content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));

		JPanel header = new JPanel(new FlowLayout(FlowLayout.LEFT));
		JTextArea title = new JTextArea(0, 30);
		title.setLineWrap(true);
		title.setEditable(false);
		title.setFocusable(false);
		title.setBackground(this.getBackground());
		title.setText(Constants.ADDINFO);
		header.add(title);
		content.add(header);

		JScrollPane contentPane = new JScrollPane(content);
		contentPane.setPreferredSize(new Dimension(400, 75));
		contentPane.setBorder(null);
		contentPane
				.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
		contentPane
				.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);


		ArrayList<JTextField> infoList = new ArrayList<JTextField>();

		for (IPAddress element : Controller.getInstance().getMultiIpList()) {
			JPanel elementPanel = new JPanel(header.getLayout());
			JLabel address = new JLabel(element.getAddress() + Constants.DOUBLE);
			elementPanel.add(address);
			JTextField text = new JTextField(20);

			elementPanel.add(text);
			content.add(elementPanel);
			infoList.add(text);
		}
		Controller.getInstance().setIpInfoList(infoList);
		this.add(contentPane);


	}

}
